function grep = gs_gridReport(GSS)
%gs_gridReport 
%
%   grep = gs_gridReport(GSS)
%
% This function generates a grid report with such information from GSS: 
%   fvx, fvy: down-left corner;
%   lvx, lvy: top-right corner;
%   nx, ny  : grid elments along x,y;
%   dx, dy  : x-,y-grid pass.

% G. Teza, 2005, 2022

dx = GSS.XGridStep;
dy = GSS.YGridStep;

fv = GSS.DownLeftCorner;
fvx = fv(1);
fvy = fv(2);

lv = GSS.TopRightCorner;
lvx = lv(1);
lvy = lv(2);

nx = GSS.XGridNumber;
ny = GSS.YGridNumber;

sdfx = nu_dd(fvx,2);  % Ancillary function, see below
sdfy = nu_dd(fvy,2);
sdlx = nu_dd(lvx,2);
sdly = nu_dd(lvy,2);
sddx = nu_dd(dx,2);
sddy = nu_dd(dy,2);
grep = sprintf(...
    '%s\n\n%s\n %s(%s,%s), %s(%s,%s);\n\n%s\n%s%d, %s%d;\n\n%s\n%s%s m, %s%s m.',...
    'GRID REPORT','VERTICES:','FIRST:',sdfx,sdfy,'LAST:',sdlx,sdly,...
    'NUMBER OF GRID ELEMENTS:',' nx = ',nx,' ny = ',ny,...
    'GRID SPACING:',' dx = ',sddx,' dy = ',sddy);

%--- ancillary function ---

function rd = nu_dd(r,nd)
% For the representation of a number as
% '%nip.ndf', in which nip is the number of digits
% of its integer part and nf is the number of decimals.
srd = ['%' num2str(length(num2str(fix(r)))) '.' num2str(nd) 'f'];
     % (The result is the format for the representation)
rd = sprintf(sprintf('%s',srd),r);